// 加载图片
function loadImg(src) {
    // pending
    return new Promise((resolve, reject) => {
        const img = document.createElement('img')
        img.onload = () => {
            resolve(img) //resolved
        }
        img.onerror = () => {
            reject(new Error('图片加载失败')) //rejected
        }
        img.src = src
    })
}

const url = 'https://img.mukewang.com/szimg/5e3cfea008e9a61b06000338-358-201.jpg'
const p = loadImg(url)
p.then(img => {
    console.log(img.width)
    return img
}).then(img => {
    console.log(img.height)
}).catch(ex => {
    console.log(ex)
})
